home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / ecstr2.arc / STRRPT.C < prev    next >
C/C++ Source or Header  |  1987-03-04  |  703b  |  28 lines

  1. /*  File   : strrpt.c
  2.     Author : Richard A. O'Keefe.
  3.     Updated: 20 April 1984
  4.     Defines: strrpt()
  5.  
  6.     strrpt(dst, src, k) "RePeaTs" the string src into dst k times.  E.g.
  7.     strrpt(dst, "hack ", 2) will move "hack hack" to dst.  If k <= 0 it
  8.     does nothing.  The result is the number of characters moved, except
  9.     for the closing NUL.  src may be "" but may not of course be NullS.
  10. */
  11.  
  12. #include "strings.h"
  13.  
  14. int strrpt(dst, src, k)
  15.     register char *dst;
  16.     char *src;
  17.     int k;
  18.     {
  19.        char *save;
  20.  
  21.        for (save = dst; --k >= 0; --dst) {
  22.            register char *p;
  23.            for (p = src; *dst++ = *p++; ) ;
  24.        }
  25.        return dst-save;
  26.     }
  27.  
  28.